package demo.office;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author guankaiqiang
 * @date 2017/12/19
 */
public enum RmaType {
    RETURN(1, "T", "退货退款", 40),

    EXCHANGE(2, "H", "换货", 20),

    REDELIVER(3, "B", "补货", 10),

    DISCOUNT_REFUND(4, "Z", "破损赔偿", 30),

    REFUND(5, "TK", "仅退款", 50),

    CHECK_PRODUCED_DATE(6, "P", "查询生产日期", 100),

    CHECK_LOGISTICS_INFO(7, "L", "物流查询", 200),

    UPDATE_CUSTOMIZED_INFO(8, "C", "更改定制信息", 300),

    UPDATE_RECEIVER_INFO(9, "R", "联系供应商更改收件人信息", 400),

    SEVEN_DAY_PREMIUM(10, "Q", "七天保价", 0),

    OFFLINE_RETURN(11, "RO", "线下退货退款", 0),

    EXCESS_REFUND(12, "ER", "超额退款", 0),

    OFFLINE_EXCHANGE(13, "OE", "线下换货", 0);
    /**
     * 售后问题咨询
     */
    public static final List<RmaType> AFTER_SALES_CONSULTING = Arrays.asList(CHECK_PRODUCED_DATE, CHECK_LOGISTICS_INFO,
        UPDATE_CUSTOMIZED_INFO, UPDATE_RECEIVER_INFO);
    /**
     * 线下店售后类型
     */
    public static final List<RmaType> OFFLINE_RMA_TYPES = Arrays.asList(OFFLINE_RETURN,OFFLINE_EXCHANGE);

    /**
     * 允许c端发起和展示的售后单
     */
    public static final List<Short> CUSTOMER_SUPPORT_RMA_TYPE = Collections.unmodifiableList(
        Stream.of(RETURN, EXCHANGE, REDELIVER, DISCOUNT_REFUND, REFUND, SEVEN_DAY_PREMIUM, CHECK_LOGISTICS_INFO,
            UPDATE_RECEIVER_INFO,OFFLINE_RETURN,OFFLINE_EXCHANGE)
            .map(RmaType::value)
            .collect(Collectors.toList()));

    /**
     * 退换补寄损溢赔偿
     */
    public static final List<Short> NORMAL_RMA_TYPE = Collections.unmodifiableList(
        Stream.of(RETURN, EXCHANGE, REDELIVER, DISCOUNT_REFUND, REFUND)
            .map(RmaType::value)
            .collect(Collectors.toList()));

    /**
     * 涉及到退货的售后流程
     */
    public static final List<Short> RETURN_GOODS_RMA_TYPE = Collections.unmodifiableList(
        Stream.of(RETURN, REFUND, EXCHANGE, OFFLINE_RETURN).map(RmaType::value)
            .collect(Collectors.toList()));

    short value;
    String rmaPrefix;
    String desc;
    int weight;

    RmaType(int value, String rmaPrefix, String desc, int weight) {
        this.value = (short)value;
        this.rmaPrefix = rmaPrefix;
        this.desc = desc;
        this.weight = weight;
    }

    public short value() { return value; }

    public String getRmaPrefix() {
        return rmaPrefix;
    }

    public int getWeight() {
        return weight;
    }

    public String getDesc() {
        return desc;
    }

    public boolean isEqual(short type) {
        return this.value == type;
    }

    public boolean isEqual(int type) {
        return this.value == type;
    }
}
